<template>
  <div>
    <puplic-modal
      width="1120px"
      :footer="false"
      :title="title"
      modalStyle="informationIssue-detailModal"
      :publicVisible="publicVisible"
      @handleOk="handleOk"
      @cancel="publicVisible = false"
    >
      <div slot="content" class="inspectPdf" style="padding-bottom: 20px">
        <!-- 电子文书 附件1  检查-->
        <div class="matterList page" v-if="records.checkType == 1">
          <div class="recordTable">
            <div class="details-table detailModal">
              <div class="books-content">
                <div class="books-topic">
                  <div>
                    {{ basePoliceInfo.policeAgencyName }}
                  </div>
                  <div>责令整改通知书</div>
                  <div>
                    {{ areaPoliceInfo.postShopName }}行罚决字 【{{ fullYear }}】
                    {{ policeCheckUnqualifiedInfoBook.orderNo }}号
                  </div>
                </div>

                <div class="books-article">
                  <div class="artTwo">
                    <span class="article-title">违法行为人</span>
                    <span class="article-con">
                      {{ companyInfo.companyName }},地址{{ companyInfo.addressDetail }}，法定代表人{{
                        legalInfo.legalPersonName
                      }},{{ legalInfo.sex == 1 ? '男' : '女' }},{{
                        formatters(legalInfo.birth, 'wordDay')
                      }}出生,身份证号码为{{ legalInfo.idCard }}。
                    </span>
                  </div>

                  <div class="artTwo">
                    <span class="article-title">现查明</span>
                    <span class="article-con">
                      {{ formatters(policeCheckTaskInfoBook.checkTime, 'wordTime') }},{{
                        areaPoliceInfo.policeAgencyName
                      }}
                      治安大队对{{ basePoliceInfo.policeAgencyName }}辖区{{
                        companyInfo.companyName
                      }}检查时,发现该场所存在:
                      <block v-for="(rlist, i) in descriptionOfViolationInfoList" :key="i">
                        {{ rlist.descriptionOfViolation }}
                        <block
                          v-if="
                            descriptionOfViolationInfoList.length >= 2 && i + 1 != descriptionOfViolationInfoList.length
                          "
                        >
                          ;
                        </block> </block
                      >的违法行为。
                    </span>
                    <!-- 。 -->
                  </div>

                  <div class="artTwo">
                    <!-- 写死 -->
                    <span class="article-title">以上事实有</span>
                    <span class="article-con"> 违法行为人供述和辩解、证人证言、书证、物证、试听资料笔录 </span>
                    <span class="article-title">等证据证实。</span>
                  </div>

                  <div class="artTwo">
                    <span class="article-title">根据</span>
                    <span class="article-con">
                      <block v-for="(rlist, i) in regulationsInfoList" :key="i">
                        《{{ rlist.regulationsName }}》中
                        <block v-for="(rlistItem, index) in rlist.regulationsArticleInfoList" :key="index">
                          {{ rlistItem.regulationsArticleNo }}
                          <block v-if="rlist.regulationsArticleInfoList.length > index + 1"> 、 </block>
                        </block>
                      </block>
                    </span>
                    <span class="article-title">之规定。现决定</span>
                    <span class="article-con">
                      给予{{ companyInfo.companyName
                      }}{{ policeCheckUnqualifiedInfoBook.rectificationType == 1 ? '限期整改' : '停业整顿' }}的行政处罚
                      <block v-if="policeCheckUnqualifiedInfoBook.isFined">
                        并处罚款{{ policeCheckUnqualifiedInfoBook.finedMoney }}元。
                      </block>
                      <block v-else>。</block>
                    </span>
                  </div>

                  <div class="artTwo">
                    <span class="article-title">执行方式和期限</span>
                    <span class="article-con">
                      限你({{ companyInfo.companyName }} )于{{
                        formatters(policeCheckUnqualifiedInfoBook.penaltyEndTime, 'wordDay')
                      }}前完成以上处罚决定。
                    </span>
                  </div>

                  <!-- <div class="artTwo">  不要删
                <span class="article-title"> 如不服本决定，可以在收到本决定书之日起六十日内向 </span>
                <span class="article-con">
                  {{ governmentName }}
                </span>
                <span class="article-title">申请行政复议或者在六个月依法向</span>
                <span class="article-con">
                  {{ courtName }}
                </span>
                <span class="article-title">提起行政诉讼。</span>
              </div> -->
                  <div class="artTwo">
                    <span class="article-title">责令整改通知书已向我宣告并送达。</span>
                  </div>

                  <div class="seal-person">
                    <div class="artTwo">
                      <span class="article-title"> 被处罚人:{{ legalInfo.legalPersonName }} </span>
                    </div>

                    <div class="stampTime">
                      <img :src="imgPrefix + basePoliceInfo.electronicSignature" mode="" />
                      <div class="poView">
                        <div style="margin-bottom: 10px">{{ basePoliceInfo.policeAgencyName }}</div>
                        <div>{{ formatters(policeCheckTaskInfoBook.checkTime, 'wordDay') }}</div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- 电子文书 附件2  复查-->
        <div class="matterList page" v-else>
          <div class="recordTable">
            <div class="details-table detailModal">
              <div class="books-content">
                <div class="books-topic">
                  <div>
                    {{ basePoliceInfo.policeAgencyName }}
                  </div>
                  <div>责令整改通知书</div>
                  <div>
                    {{ areaPoliceInfoReview.postShopName }}行罚决字 【{{ fullYear }}】
                    {{ policeCheckUnqualifiedInfoBookReview.orderNo }}号
                  </div>
                </div>

                <div class="books-article">
                  <div class="artTwo">
                    <span class="article-title">违法行为人</span>
                    <span class="article-con">
                      {{ companyInfoReview.companyName }},地址{{ companyInfoReview.addressDetail }}，法定代表人{{
                        legalInfoReview.legalPersonName
                      }},{{ legalInfoReview.sex == 1 ? '男' : '女' }},{{
                        formatters(legalInfoReview.birth, 'wordDay')
                      }}出生,身份证号码为{{ legalInfoReview.idCard }}。
                    </span>
                  </div>

                  <div class="artTwo">
                    <span class="article-title">{{ formatters(policeCheckTaskInfoBook.checkTime, 'wordTime') }}</span>
                    <span class="article-con">
                      {{ areaPoliceInfoReview.policeAgencyName }}治安大队对{{
                        basePoliceInfoReview.policeAgencyName
                      }}辖区{{ companyInfoReview.companyName }}检查时,发现该场所存在:
                      <block v-for="(rlist, i) in descriptionOfViolationInfoList" :key="i">
                        {{ rlist.descriptionOfViolation }}
                        <block
                          v-if="
                            descriptionOfViolationInfoList.length >= 2 && i + 1 != descriptionOfViolationInfoList.length
                          "
                        >
                          ;
                        </block>
                      </block>
                    </span>
                    <!-- 。 -->
                    <span class="article-title">
                      的违法行为。经{{ formatters(policeCheckTaskInfoBookReview.checkTime, 'wordTime') }}复查,
                    </span>
                    <span class="article-con">
                      发现该场所仍然存在:
                      <block v-for="(rlist, i) in descriptionOfViolationInfoListReview" :key="i">
                        {{ rlist.descriptionOfViolation }}
                        <block
                          v-if="
                            policeCheckTaskInfoBookReview.length >= 2 && i + 1 != policeCheckTaskInfoBookReview.length
                          "
                        >
                          ;
                        </block>
                      </block>
                      的违法行为。
                    </span>
                    <span class="article-title">故对该场所做出</span>
                    <span class="article-con">
                      {{ policeCheckTaskInfoBookReview.rectificationType == 1 ? '限期整改' : '停业整顿' }}
                    </span>
                    <span class="article-title">的行政处罚。</span>
                  </div>

                  <div class="artTwo">
                    <!-- 写死 -->
                    <span class="article-title">以上事实有</span>
                    <span class="article-con"> 违法行为人供述和辩解、证人证言、书证、物证、试听资料笔录 </span>
                    <span class="article-title">等证据证实。</span>
                  </div>

                  <div class="artTwo">
                    <span class="article-title">执行方式和期限</span>
                    <span class="article-con">
                      限你({{ companyInfoReview.companyName }} )于{{
                        formatters(policeCheckUnqualifiedInfoBookReview.penaltyEndTime, 'wordDay')
                      }}前完成以上处罚决定。
                    </span>
                  </div>

                  <!-- <div class="artTwo">   不要删
                <span class="article-title"> 如不服本决定，可以在收到本决定书之日起六十日内向 </span>
                <span class="article-con">
                  {{ governmentNameReview }}
                </span>
                <span class="article-title">申请行政复议或者在六个月依法向</span>
                <span class="article-con">
                  {{ courtNameReview }}
                </span>
                <span class="article-title">提起行政诉讼。</span>
              </div> -->

                  <div class="artTwo">
                    <span class="article-title">责令整改通知书已向我宣告并送达。</span>
                  </div>

                  <div class="seal-person">
                    <div class="artTwo">
                      <span class="article-title"> 被处罚人:{{ legalInfoReview.legalPersonName }} </span>
                    </div>

                    <div class="stampTime">
                      <img :src="imgPrefix + basePoliceInfo.electronicSignature" mode="" />
                      <div class="poView">
                        <!-- areaPoliceInfoReview.policeAgencyName  -->
                        <div style="margin-bottom: 10px">{{ basePoliceInfo.policeAgencyName }}</div>
                        <div>{{ formatters(policeCheckTaskInfoBookReview.checkTime, 'wordDay') }}</div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div slot="footer"></div>
    </puplic-modal>
  </div>
</template>
<script>
import { comMethods } from '@/mixins/comMethods'
import puplicModal from '@/components/publicModal'
import { checkTaskRecord, electronicRecords } from '@/api/goover'
import { formatters, formattersWord } from '@/utils/util.js'
export default {
  mixins: [comMethods],
  components: { puplicModal },
  name: 'informationIssue-detailModal',
  data() {
    return {
      publicVisible: false,
      records: {},
      fullYear: new Date().getFullYear(),
      title: '检查单详情',
      policeCheckTaskInfo: {},
      policeCheckUnqualifiedInfo: {},
      policeCheckDetailInfoList: {},
      policeCheckCategoryInfoList: {},
      // 复查单
      policeCheckTaskInfoReview: {},
      policeCheckCategoryInfoListReview: {},
      policeCheckUnqualifiedInfoReview: {},
      // 检查 电子文书
      areaPoliceInfo: {},
      basePoliceInfo: {},
      companyInfo: {},
      courtName: {},
      governmentName: {},
      informationInfo: {},
      legalInfo: {},
      policeCheckTaskInfoBook: {},
      policeCheckUnqualifiedInfoBook: {},
      regulationsInfoList: {},
      descriptionOfViolationInfoList: {},
      //复查 电子文书
      areaPoliceInfoReview: {},
      basePoliceInfoReview: {},
      companyInfoReview: {},
      courtNameReview: {},
      governmentNameReview: {},
      informationInfoReview: {},
      legalInfoReview: {},
      policeCheckTaskInfoBookReview: {},
      policeCheckUnqualifiedInfoBookReview: {},
      regulationsInfoListReview: {},
      descriptionOfViolationInfoListReview: {},
      imgPrefix: '',
    }
  },
  methods: {
    formatters,
    formattersWord,
    show(records) {
      console.log(records, 'records')
      this.records = records
      if (records.checkType == 1) {
        this.checkList()
      } else {
        this.title = '复查单详情'
        this.getDetailList()
      }
      this.publicVisible = true
    },
    handleOk() {
      this.publicVisible = false
    },

    checkList() {
      checkTaskRecord({ taskId: this.records.id })
        .then((res) => {
          let {
            policeCheckTaskInfo,
            policeCheckUnqualifiedInfo,
            policeCheckDetailInfoList,
            policeCheckCategoryInfoList,
          } = res.result
          this.policeCheckTaskInfo = policeCheckTaskInfo

          this.policeCheckUnqualifiedInfo = policeCheckUnqualifiedInfo
          this.policeCheckDetailInfoList = policeCheckDetailInfoList
          this.policeCheckCategoryInfoList = policeCheckCategoryInfoList

          return this.policeCheckUnqualifiedInfo.id
        })
        .then((res2) => {
          this.crpBookList(res2)
        })
    },

    getDetailList() {
      // 检查单
      checkTaskRecord({ taskId: this.records.id })
        .then((res) => {
          let { policeCheckTaskInfo, policeCheckUnqualifiedInfo, policeCheckCategoryInfoList } = res.result
          this.policeCheckTaskInfo = policeCheckTaskInfo
          this.policeCheckUnqualifiedInfo = policeCheckUnqualifiedInfo
          this.policeCheckCategoryInfoList = policeCheckCategoryInfoList

          return this.policeCheckUnqualifiedInfo.id
        })
        .then((res2) => {
          this.crpBookList(res2)
        })

      // 复查单
      checkTaskRecord({ taskId: this.records.id })
        .then((res) => {
          let { policeCheckTaskInfo, policeCheckCategoryInfoList, policeCheckUnqualifiedInfo } = res.result
          this.policeCheckTaskInfoReview = policeCheckTaskInfo
          this.policeCheckCategoryInfoListReview = policeCheckCategoryInfoList
          this.policeCheckUnqualifiedInfoReview = policeCheckUnqualifiedInfo

          return this.policeCheckUnqualifiedInfoReview.id
        })
        .then((res2) => {
          if (this.records.checkResult == 2) {
            this.crpBookList2(res2)
          }
        })
    },
    // 检查单 电子文书
    crpBookList(res2) {
      electronicRecords(res2).then((resBook) => {
        let {
          areaPoliceInfo,
          basePoliceInfo,
          companyInfo,
          courtName,
          governmentName,
          informationInfo,
          legalInfo,
          policeCheckTaskInfo,
          policeCheckUnqualifiedInfo,
          regulationsInfoList,
          descriptionOfViolationInfoList,
        } = resBook.result || {}
        this.areaPoliceInfo = areaPoliceInfo
        this.basePoliceInfo = basePoliceInfo
        this.companyInfo = companyInfo
        this.courtName = courtName
        this.governmentName = governmentName
        this.informationInfo = informationInfo
        this.legalInfo = legalInfo
        this.policeCheckTaskInfoBook = policeCheckTaskInfo
        this.policeCheckUnqualifiedInfoBook = policeCheckUnqualifiedInfo
        this.regulationsInfoList = regulationsInfoList
        this.descriptionOfViolationInfoList = descriptionOfViolationInfoList
      })
    },
    // 复查单 电子文书
    crpBookList2(res2) {
      electronicRecords(res2).then((resBook) => {
        let {
          areaPoliceInfo,
          basePoliceInfo,
          companyInfo,
          courtName,
          governmentName,
          informationInfo,
          legalInfo,
          policeCheckTaskInfo,
          policeCheckUnqualifiedInfo,
          regulationsInfoList,
          descriptionOfViolationInfoList,
        } = resBook.result || {}
        this.areaPoliceInfoReview = areaPoliceInfo
        this.basePoliceInfoReview = basePoliceInfo
        this.companyInfoReview = companyInfo
        this.courtNameReview = courtName
        this.governmentNameReview = governmentName
        this.informationInfoReview = informationInfo
        this.legalInfoReview = legalInfo
        this.policeCheckTaskInfoBookReview = policeCheckTaskInfo
        this.policeCheckUnqualifiedInfoBookReview = policeCheckUnqualifiedInfo
        this.regulationsInfoListReview = regulationsInfoList
        this.descriptionOfViolationInfoListReview = descriptionOfViolationInfoList
      })
    },
  },
}
</script>

<style scoped lang="less">
.accessory_title {
  margin: 10px 0;
  color: #9b9b9b;
}

.books-content {
  padding: 15px;
  border: 1px solid #830707;

  .books-topic {
    color: #9e520a;
    text-align: center;
    font-weight: 500;
    line-height: 50px;

    div:nth-of-type(1) {
      font-size: 24px;
    }

    div:nth-of-type(2) {
      font-size: 40px;
      font-weight: 700;
    }

    div:nth-of-type(3) {
      color: #232222;
      font-size: 14px;
      text-align: right;
    }
  }

  .books-article {
    padding: 0 10px;
    color: #848484;
    font-size: 16px;
    font-weight: 500;

    .artTwo {
      text-indent: 2em;
      line-height: 30px;
      .article-title {
        color: #000000;
        font-size: 16px;
      }

      .article-con {
        padding-bottom: 2px;
        border-bottom: 1px solid #830707;
      }
    }

    .seal-time {
      position: relative;
      padding-top: 2vh;
      text-align: right;
      font-size: 18px;
      color: #232222;
      line-height: 50px;

      .seal-date {
        position: absolute;
        display: inline-block;
        right: 10px;
        top: 45px;
      }

      .seal-image {
        width: 150px;
        height: 150px;
      }
    }

    .seal-person {
      display: flex;
      justify-content: space-between;
      position: relative;

      .stampTime {
        min-width: 220px;
        max-width: 700px;
        text-align: right;
        img {
          width: 150px;
          height: 150px;
        }

        .poView {
          position: absolute;
          top: 5px;
          right: 0;
          .poName {
            color: #000000;
            font-size: 24px;
          }
        }
      }
    }
  }
}
</style>
